<template>
	<view>
		<page-head :title="'发票信息'" :headtype="2"></page-head>
		<view class="fromblock">
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt">*</text> 发票类型</view>
				<view class="formitem-msg flex" style="background:#fff;" v-if="noedit == 1">
					<view class="invotype" @click="invotype=1" :class="invotype == 1 ? 'invotypeactive':''">电子普通发票</view>
					<view class="invotype" @click="invotype=2" :class="invotype == 2 ? 'invotypeactive':''">专用发票</view>
				</view>
				<view class="formitem-msg flex" style="background:#fff;" v-if="noedit == 2">
					<view class="invotype" :class="invotype == 1 ? 'invotypeactive':''">电子普通发票</view>
					<view class="invotype" :class="invotype == 2 ? 'invotypeactive':''">专用发票</view>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt">*</text> 抬头名称</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" v-model="look" placeholder="请输入抬头名称"/>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt">*</text> 单位税号</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" v-model="taxid" placeholder="请输入单位税号"/>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt" v-if="invotype == 2">*</text> 注册地址</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" v-model="site" placeholder="请输入注册地址"/>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt" v-if="invotype == 2">*</text> 注册电话</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" maxlength="11" v-model="phone" placeholder="请输入注册电话"/>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt" v-if="invotype == 2">*</text> 开户银行</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" v-model="bankname" placeholder="请输入开户银行"/>
				</view>
			</view>
			<view class="formitem marginAuto">
				<view class="formitem-title"><text class="bt" v-if="invotype == 2">*</text> 银行账户</view>
				<view class="formitem-msg" style="background:#fff;">
					<input class="msginput" :disabled="noedit == 1 ? false : true" type="text" v-model="bankcode" placeholder="请输入银行账户"/>
				</view>
			</view>
		</view>
		<view class="marginAuto" style="width:600rpx;margin-top:30rpx;" v-if="noedit == 1">
			<uv-button text="确定" @click="enter()" :customStyle="{
				'background':'#2340FF',
				'color':'#fff',
				'font-size':'30rpx',
				'width':'600rpx',
				'height':'100rpx',
				'border-radius':'20rpx'
			}"></uv-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				noedit:1,  // 1可输入 2仅展示
				invotype:1,
				look:'',
				taxid:'',
				site:'',
				phone:'',
				bankname:'',
				bankcode:''
			};
		},
		onLoad(option) {
			this.noedit = option.noedit || 1;
			let addmyinvoice = uni.getStorageSync('addmyinvoice');
			this.invotype = addmyinvoice.invoice_type || 1;
			this.look = addmyinvoice.invoice_title || '';
			this.taxid = addmyinvoice.invoice_tax || '';
			this.site = addmyinvoice.reg_address || '';
			this.phone = addmyinvoice.reg_tel || '';
			this.bankname = addmyinvoice.bank_name || '';
			this.bankcode = addmyinvoice.bank_account || '';
		},
		methods: {
			enter(){
				let sendData = {
					invoice_type:this.invotype,
					invoice_title:this.look,
					invoice_tax:this.taxid,
					reg_address:this.site,
					reg_tel:this.phone,
					bank_name:this.bankname,
					bank_account:this.bankcode
				}
				if(this.look == '' || this.taxid== ''){
					this.apifun.toast('请信息补充完整')
					return false
				};
				if(this.invotype == 2){
					if(this.site == '' || this.phone == '' || this.bankname== '' || this.bankcode == ''){
						this.apifun.toast('请信息补充完整')
						return false
					};
				};
				uni.setStorageSync('addmyinvoice', sendData);
				setTimeout(()=>{
					this.apifun.goback()
				},300)
			}
		},
	};
</script>

<style scoped lang="scss">
	page{
		background-color: #FBFBFB;
		padding-bottom: 100rpx;
	}
	.fromblock{
		margin-top: 20rpx;
		.formitem{
			width:90%;
			.formitem-title{
				font-size: 30rpx;
				color: #333333;
				.bt{
					color:#E51818;
				}
			}
			.formitem-msg{
				flex: 1;
				border-radius:10rpx;
				padding: 0 40rpx;
				margin: 20rpx auto;
				.invotype{
					padding: 0 20rpx;
					line-height:56rpx;
					background-color:#F4F4F4;
					color: #999;
					font-size: 30rpx;
					border-radius: 10rpx;
					border: 1px solid #F4F4F4;
					margin-right: 20rpx;
				}
				.invotypeactive{
					border-color:#2340FF;
					color: #2340FF;
					background-color:#EFF1FF;
				}
				.msginput{
					flex: 1;
					height:100rpx;
					line-height: 100rpx;
					font-size: 30rpx;
					color: #333;
				}
				.compantypeeach{
					line-height: 100rpx;
					margin-right:100rpx;
					.companticon{
						margin-top:28rpx;
						margin-right: 10rpx;
					}
					.companttitle{
						font-size: 30rpx;
						color: #999999;
					}
				}
				.upload{
					position:relative;
					width: 200rpx;
					height: 200rpx;
					border-radius:10rpx;
					background-color: #F3F3F3;
					.icon{
						
					}
					.uploadimg{
						position: absolute;
						left: 0;
						top: 0;
						z-index: 2;
						width: 200rpx;
						height: 200rpx;
						border-radius:10rpx;
					}
				}
				.invoicemsg{
					line-height: 100rpx;
					color:#999999;
					justify-content: space-between;
					.icon{
						margin-top:30rpx;
					}
				}
			}
		}
	}
</style>